package com.cn.jinl.controller;

import com.cn.jinl.api.IOnDutyBgService;
import com.cn.jinl.domain.OnDutyBg;
import com.cn.jinl.utils.CommonUtil;
import com.cn.jinl.utils.JsonResponse;
import com.cn.jinl.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/bg")
public class OnDutyBgController {

    @Autowired
    private IOnDutyBgService onDutyBgService;

    @ResponseBody
    @RequestMapping("/getOnDutyBgList/{frontToken}")
    public JsonResponse<List<OnDutyBg>> getOnDutyBgList(QueryForm queryForm, @PathVariable(value = "frontToken", required = true) String frontToken) throws Exception {
        JsonResponse<List<OnDutyBg>> response = new JsonResponse<List<OnDutyBg>>();
        List<OnDutyBg> result = onDutyBgService.getOnDutyBgList(queryForm);
        response.setResult(result);
        response.setSuccess(true);
        return response;
    }


    @RequestMapping("/updateOnDutyBg/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updateOnDutyBg(OnDutyBg onDutyBg, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = onDutyBgService.updateOnDutyBg(onDutyBg);
        return CommonUtil.getResponseData(response,result);
    }
}
